﻿// C11Feature.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include "People.h"
#include <string>
#include <iostream>


typedef People *PPeople;//设置类型别名
using PCPeople = const People*;//设置类型别名,c11

using namespace std;

extern int GlobalNum = 10;//声明变量中赋初始值则抵消extern,变成定义

int _tmain( int argc, _TCHAR* argv[] )
{
	People Boy{ 1000 }, *pBoy = &Boy, &rBoy = Boy;//类型说明符与标识符相关联,而非基本类型符
	People *&rpBoy = pBoy;//从标识符最近处开始读,首先是个引用,引用的类型是一个指针,即引用指针

	auto NowMoney = Boy.CostMoney( 100 );//编辑器自动推算变量类型,发生在编辑期
	decltype( ( Boy.GetAge() ) ) PeopleAge;//根据表达式计算类类型,不会真实执行表达式,特别注意容易计算出引用类型!
	PeopleAge = Boy.GetAge();

	People ClassMates[5] = { { "Li Xia", 100 }, 800, 500 };//统一初始化

	for ( auto& cMate : ClassMates )//范围for c11新增
	{
		cout << cMate.Name << "'s Age is " << (int)cMate.GetAge() << endl;
	}

	return 0;
}
